﻿@using DTcms.Common;
@{
    ViewBag.Title = "图文回复管理";
}
<div class="pageheader">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
            <li><a href="javascript:;">应用管理</a> </li>
            <li><a href="javascript:;">微信管理</a> </li>
            <li><a href="javascript:;">图文回复</a> </li>
        </ul>
    </div>
</div>
<div class="layui-fluid">
    <div class="layui-card layui-tab">
        <div class="layui-card-body table-tool-mini">
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="menu-list">
                        <div class="layui-inline">
                            <div class="layui-input-inline mr0">
                                <input id="txtKeywords" class="layui-input" type="text" placeholder="输入关键字" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn layui-btn-normal layui-btn-sm" id="btnSearchAuth" data-type="btnSearch">
                                <i class="layui-icon">&#xe615;</i>搜索
                            </button>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-btn-group">
                            <a data-type="btnAdd" class="layui-btn icon-btn layui-btn-normal layui-btn-sm" href="../weixin/picture_edit?action=@DTEnums.ActionEnum.Add"><i class="iconfont icon-close1"></i><span> 新增</span></a>
                            <a data-type="btnDelete" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="iconfont icon-delete"></i><span> 删除</span></a>
                        </div>
                    </div>
                </div>
            </div>
            <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                <thead>
                    <tr>
                        <th lay-data="{checkbox:true}"></th>
                        <th lay-data="{field:'account_id'}">公众账户</th>
                        <th lay-data="{field:'keywords'}">关健词</th>
                        <th lay-data="{field:'sort_id',edit: 'text'}">排序</th>
                        <th lay-data="{field:'count'}">图片数量</th>
                        <th lay-data="{field:'is_like_query', templet:'#is_like_query'}">模糊区配</th>
                        <th lay-data="{field:'add_time'}">添加时间</th>
                        <th lay-data="{templet: '#barDemo'}">操作</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
<script type="text/html" id="is_like_query">
    {{#
    var text = d.is_like_query == 0 ? "text-success icon-close" : "text-warning icon-check";
    return '<i class="simple ' + text + '"></i>';
    }}
</script>
<script type="text/html" id="barDemo">
    <a href="../weixin/picture_edit?action=@DTEnums.ActionEnum.Edit&id={{d.id}}" class="layui-btn layui-btn-primary layui-btn-xs">修改</a>
</script>
@section Scripts{
    <script type="text/javascript">
        layui.use(['table', 'cmswh'], function () {
            var table = layui.table, form = layui.form, cmswh = layui.cmswh, $ = layui.jquery;
            cmswh.dataBind('PictureList');

            //监听单元格编辑
            table.on('edit(ltable)', function (obj) {
                cmswh.request("PictureFiledSave", "POST", { field: obj.field, value: obj.value, id: obj.data.id });
            });
            var active = {
                btnDelete: function () {
                    cmswh.batOperate('PictureDelete', 'id');
                },
                btnSearch: function () {
                    table.reload('ltable', { page: { curr: 1 }, where: getcond() });
                }
            };
            $('.layui-inline .layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
            /*拼接条件返回postdata*/
            function getcond() {
                var keywords = $("#txtKeywords").val();
                var postdata = { keywords: keywords };
                return postdata;
            }
        });
    </script>
}